/**
 * 模态框
 */

(function($) {
	$.jqm = {

	}
})(jQuery);

if (typeof (jqm) == 'undefined') {
	jqm = new Object();
}

/**
 * 消息模态框
 * 
 * @param o
 *            标题、内容、宽度
 */
jqm.message = function(o) {
	var op = {
		title : '确认',
		content : '内容'
	};
	op.title = o.title ? o.title : op.title;
	op.content = o.content ? o.content : op.content;
	if ($('#messageModal').length) {
		$('#messageModal').remove();
	}
	var messageModal = '<div class="modal fade" id="messageModal" tabindex="-1" role="dialog" aria-hidden="true">'
			+ '<div class="modal-dialog">' + op.content + '</div></div>';
	$('body').append(messageModal);
	$('#messageModal').modal('show');
};

/**
 * 确认模态框
 * 
 * @param o
 *            标题、内容、确认后执行的方法
 */
jqm.confirm = function(o) {
	var op = {
		title : '确认',
		content : '内容',
		onConfirm : null,
		self : null
	};
	op.title = o.title ? o.title : op.title;
	op.content = o.content ? o.content : op.content;
	op.onConfirm = o.onConfirm ? o.onConfirm : op.onConfirm;
	op.self = o.self ? o.self : op.self;
	if ($('#confirmModal').length) {
		$('#confirmModal').remove();
	}
	var confirmModal = '<div class="modal fade" id="confirmModal" tabindex="-1" role="dialog" aria-hidden="true">'
			+ '<div class="modal-dialog"><div class="modal-content"><div class="modal-body">'
			+ op.content
			+ '</div><div class="modal-footer"><button type="button" class="btn btn-default" data-dismiss="modal">取消</button>'
			+ '<button id="confirmModalSure" type="button" class="btn btn-primary">确定</button></div></div></div></div>';
	$('body').append(confirmModal);
	$('#confirmModal').modal('show');
	$('#confirmModalSure').click(function() {
		$('#confirmModal').modal('hide');
		if (op.onConfirm) {
			op.onConfirm.call(op.self);
		}
	});
};